package cn.wildfirechat.app.jpa;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.time.LocalDateTime;

@RepositoryRestResource()
public interface FriendRepository  extends CrudRepository<Friend, Long> {
    @Query(value = "SELECT * FROM add_friend WHERE owner_id = ?1 and end_time >= ?2 ORDER BY end_time DESC LIMIT 1", nativeQuery = true)
    Friend findByOwnerId(String userId, LocalDateTime now);
}
